package inc.jmc.cyberboard.ui.ventas.common;
/*
 * ProductoIconRenderer.java
 *
 * Created on 29 de enero de 2007, 04:59 PM
 */

import inc.jmc.cyberboard.log.Log;
import inc.jmc.cyberboard.entitybeans.ProductosWithIconos;
import inc.jmc.cyberboard.ui.ventas.DetalleGridVentas;
import inc.jmc.cyberboard.ztrashcan.*;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author  JOlguin01
 */
public class ProductoIconRenderer extends javax.swing.JPanel implements TableCellRenderer {
    
    ImageIcon imagen;
    String descrip;
    String path;
    private ProductosWithIconos producto;
    private DetalleGridVentas detalleVentas;
    public ProductoIconRenderer() {
        initComponents();
        
    }
    
    public ProductoIconRenderer(ImageIcon imagen,String descrip,ProductosWithIconos producto,DetalleGridVentas detalleVentas) {
        this.imagen=imagen;
        this.descrip = descrip;
        this.producto=producto;
        this.detalleVentas = detalleVentas;
        initComponents();
        descripLabel.setText(descrip);
        imagenLabel.setIcon(imagen);
        this.setBackground(new java.awt.Color(238, 253, 255));
        this.setPreferredSize(new Dimension(100,100));
        this.updateUI();
        
    }
    public ProductosWithIconos getProducto() {
        return producto;
    }

    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        imagenLabel = new javax.swing.JLabel();
        descripLabel = new javax.swing.JLabel();

        setLayout(new java.awt.BorderLayout());

        jPanel1.setLayout(new java.awt.GridLayout(0, 2));

        jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jPanel1MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jPanel1MouseExited(evt);
            }
        });

        imagenLabel.setBackground(new java.awt.Color(238, 253, 255));
        jPanel1.add(imagenLabel);

        descripLabel.setBackground(new java.awt.Color(238, 253, 255));
        descripLabel.setText("jLabel2");
        descripLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                descripLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                descripLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                descripLabelMouseExited(evt);
            }
        });

        jPanel1.add(descripLabel);

        add(jPanel1, java.awt.BorderLayout.CENTER);

    }// </editor-fold>//GEN-END:initComponents

    private void descripLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_descripLabelMouseExited

        descripLabel.setBorder(null);
        jPanel1.updateUI();
    }//GEN-LAST:event_descripLabelMouseExited

    private void descripLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_descripLabelMouseEntered

        descripLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.updateUI();
        
    }//GEN-LAST:event_descripLabelMouseEntered

    private void descripLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_descripLabelMouseClicked

        ArrayList arry = new ArrayList();
        arry.add(this.producto);
        this.detalleVentas.addItems(arry);
        
        
    }//GEN-LAST:event_descripLabelMouseClicked

    private void jPanel1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MouseEntered

        descripLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.updateUI();
    }//GEN-LAST:event_jPanel1MouseEntered

    private void jPanel1MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MouseExited

        descripLabel.setBorder(null);
        jPanel1.updateUI();
    }//GEN-LAST:event_jPanel1MouseExited

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        return this;
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel descripLabel;
    private javax.swing.JLabel imagenLabel;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
    
}
